package com.duoketech.service.web.receiver;
import com.duoketech.service.AbstractService;
import com.duoketech.model.receiver.Receiver;
import com.duoketech.exception.ValidateException;
import com.duoketech.utils.search.QueryConstructor;
import com.duoketech.utils.validator.Validator;
import com.duoketech.utils.validator.rules.string.StringLengthBetween;
import com.duoketech.utils.validator.rules.string.StringMustBeRequired;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Model;

public class ReceiverService extends AbstractService{
    public static ReceiverService ME = new ReceiverService();

    @Override
    public void validatorUpdate(Model<?> model, Kv kv) throws ValidateException {
        validatorAdd(model,kv);
    }

    @Override
    public void validatorAdd(Model<?> model, Kv kv) throws ValidateException {

        Validator validator = new Validator();
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.ID),"项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.ID),"项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.CREATE_TIME),"创建时间项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.CREATE_TIME),"创建时间项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.MODIFY_TIME),"更新时间项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.MODIFY_TIME),"更新时间项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.ADDRESS),"详情地址项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.ADDRESS),"详情地址项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.PROVINCE),"省项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.PROVINCE),"省项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.CITY),"市项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.CITY),"市项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.AREA),"区项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.AREA),"区项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.STATUS),"状态项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.STATUS),"状态项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.IS_DEFAULT),"是否为默认项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.IS_DEFAULT),"是否为默认项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.MOBILE),"姓名项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.MOBILE),"姓名项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.NAME),"手机号项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.NAME),"手机号项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.ZIP_CODE),"邮编项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.ZIP_CODE),"邮编项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.MEMBER_ID),"会员id项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.MEMBER_ID),"会员id项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.AREA_DETAIL),"详细地址项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.AREA_DETAIL),"详细地址项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.PROVINCE_CODE),"省代码项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.PROVINCE_CODE),"省代码项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.CITY_CODE),"市代码项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.CITY_CODE),"市代码项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(Receiver.AREA_CODE),"区代码项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(Receiver.AREA_CODE),"区代码项字符必须为1-50个字符",1,50));
        validator.excute();

    }

    @Override
    public void beforAdd(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterAdd(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforUpdate(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterUpdate(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforQuery(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterQuery(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforDelete(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterDelete(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public String tableName() {
        return Receiver.dao.tableName();
    }

    @Override
    public void builderSQLExpected(Model<?> model, QueryConstructor queryConstruct, Kv kv) {

    }
}